﻿using System.Collections.Generic;
using System.Linq;
using System.Xml;
using System.Xml.Schema;

namespace XmlConverter {
	class ValidationResult {
		public ValidationResult(XmlDocument document) {
			document.Validate(ValidationHandler);
		}

		void ValidationHandler(object sender, ValidationEventArgs e) {
			if (e.Severity == XmlSeverityType.Error) {
				_messages.Add(e.Message);
			}
		}

		readonly ICollection<string> _messages = new LinkedList<string>();

		public bool IsSuccess {
			get { return _messages.Count == 0; }
		}

		public override string ToString() {
			return string.Join("\n", _messages.ToArray());
		}
	}
}
